var $$ = jQuery.noConflict();
(function ($, doc) {
    document.documentElement.style.fontSize = document.documentElement.clientWidth / 6.4 + 'px';
    $.init();
    $.ready(function () {
        //获取上一页数据
        var data=JSON.parse(localStorage.getItem('userInfo'))
        //form表单
        $$('#send').on('touchend', function () {
            var i = 0;
            mui("#formData input").each(function () {
                if (!this.value || this.value.trim() == "") {
                    var label = this.previousElementSibling;
                    mui.alert(label.innerText + "不允许为空");
                    return false;
                } else {
                    i = i + 1
                }
            });
            if (i == 6) {
                ifelse()
            }
        })
        function ifelse() {
                if (/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/.test($$('#phone').val())) {
                    if(/^([1-9]{1})(\d{15}|\d{18}|\d{16})$/.test($$('#bankCard').val())){
                        if(/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/.test($$('#idCard').val())){
                            data.realName = $$("#formData input").eq(0).val()
                            data.phone =  $$("#formData input").eq(1).val()
                            data.idCard = $$("#formData input").eq(2).val()
                            data.bankCard =  $$("#formData input").eq(3).val()
                            data.address =  $$("#formData input").eq(4).val()+ $$("#formData input").eq(5).val()
                            localStorage.setItem('userInfo',JSON.stringify(data))
                            openPage('/wechat/toSmallContacts')
                        }else {
                            mui.alert("请输入正确的身份证号")
                        }
                    }else {
                        mui.alert("请输入正确的银行卡号")
                    }
                } else {
                    mui.alert("请输入正确手机号")
                }
        }

        var cityPicker3 = new $.PopPicker({
            layer: 3
        });
        cityPicker3.setData(cityData3);
        var showCityPickerButton = doc.getElementById('checkAdress');
        var adressShow = doc.getElementById('adressShow');
        showCityPickerButton.addEventListener('tap', function (event) {
            cityPicker3.show(function (items) {
                adressShow.value = (items[0] || {}).text + " " + (items[1] || {}).text + " " + (items[2] || {}).text;
                //返回 false 可以阻止选择框的关闭
                //return false;
            });
        }, false)

    });
})(mui, document);